home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d11 / nansi22b.arc / SETRAW.ASM < prev    next >
Assembly Source File  |  1987-12-03  |  1KB  |  53 lines

  1. ;---- setraw.asm ----------------------------------------------
  2.     public    getraw, setraw
  3. ;----- dos ----------------------
  4. ; Call DOS function # n.
  5. dos    macro    fn
  6.     mov    ah, fn
  7.     int    21h
  8.     endm
  9.  
  10. code    segment para public 'CODE'
  11. assume cs:code
  12. ;----- Getraw ---------------------------------------------
  13. ; Returns AX=1 if file BX is a device in raw mode; 0 otherwise.
  14. ; Returns Carry set & errorcode in AX if DOS error.
  15.  
  16. getraw    proc    near
  17.     mov    al, 0
  18.     DOS    44h        ; Get attributes
  19.     jc    gr_exit     ; bad file handle?
  20.     mov    ax, 20h
  21.     and    al, dl        ; get that bit
  22.     mov    cl, 4
  23.     shr    ax, cl
  24.     clc
  25. gr_exit:
  26.     ret
  27. getraw    endp
  28.  
  29. ;----- Setraw -------------------------------------------
  30. ; Sets Raw state of file BX to (AX != 0) if file is a device.
  31. ; Returns Carry set & errorcode in AX if DOS error.
  32. setraw    proc    near
  33.     mov    cx, ax
  34.     mov    al, 0
  35.     DOS    44h
  36.     jc    sr_exit
  37.     test    al, 80h     ; It it a device?
  38.     jz    sr_exit     ; nope- do nothing.
  39.     ; Current mode in DX; set CX = 20H if CX nonzero.
  40.     or    cx, cx
  41.     jz    sr_ax0
  42.         mov    cx, 20h
  43. sr_ax0: and    dx, 00cfh    ; clear old raw bit and hi byte,
  44.     or    dx, cx        ; set new value.
  45.     mov    al, 1
  46.     DOS    44h
  47. sr_exit:
  48.     ret
  49. setraw    endp
  50. code    ends
  51.     end
  52. ;---- end of setraw.asm ------------------------------------------
  53.